import { BaseDataListPanel } from "../BaseDataListPanel";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { MemberInfoRender } from "./MemberInfoRender";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { GuildMemberSortType } from "../info/GuildMemberSortType";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { GuildEventName } from "../GuildEventName";
type int = number;
//class MemberListPanel
    
    export  class MemberListPanel extends BaseDataListPanel
    {
        constructor()
        {
            super(titleColumn);
            titleColumn = Language.getArray(57214, "x");
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._numText = ObjCreate.createTextField("", 420, 370, 115, 20, this, new GTextFormat(FontUtil.songtiName, 12, 15788607));
            this._numText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            tileList.setStyle("cellRenderer", MemberInfoRender);
            tileList.setSize(650, 300);
            tileList.columnWidth = 575;
            bgWidth = 660;
            bgHeight = 396;
            this._posDescBtn = ObjCreate.createGButton("", 207, 8, 11, 17, this, "DescRedButton");
            this._posDescBtn.name = "positionBtn";
            this._posDescBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onDescBtnClickHandler);
            this._levelDescBtn = ObjCreate.createGButton("", 274, 8, 11, 17, this, "DescRedButton");
            this._levelDescBtn.name = "levelBtn";
            this._levelDescBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onDescBtnClickHandler);
            this._dayContriDescBtn = ObjCreate.createGButton("", 392, 8, 11, 17, this, "DescRedButton");
            this._dayContriDescBtn.name = "dayBtn";
            this._dayContriDescBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onDescBtnClickHandler);
            this._weekContriDescBtn = ObjCreate.createGButton("", 467, 8, 11, 17, this, "DescRedButton");
            this._weekContriDescBtn.name = "weekBtn";
            this._weekContriDescBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onDescBtnClickHandler);
            this._totalContriDescBtn = ObjCreate.createGButton("", 540, 8, 11, 17, this, "DescRedButton");
            this._totalContriDescBtn.name = "totalBtn";
            this._totalContriDescBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onDescBtnClickHandler);
            this._statusDescBtn = ObjCreate.createGButton("", 622, 8, 11, 17, this, "DescRedButton");
            this._statusDescBtn.name = "statusBtn";
            this._statusDescBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onDescBtnClickHandler);
            return;
        }

        public updateNumText(arg1: int, arg2: int): void
        {
            this._numText.text = Language.getString(57215) + arg1 + "/" + arg2;
            return;
        }

        /* internal  */onDescBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc2=null;
            var loc1=(arg1.target as GButton).name;
            if (loc1 != "positionBtn") 
            {
                if (loc1 != "levelBtn") 
                {
                    if (loc1 != "dayBtn") 
                    {
                        if (loc1 != "weekBtn") 
                        {
                            if (loc1 != "totalBtn") 
                            {
                                if (loc1 == "statusBtn") 
                                {
                                    loc2 = GuildMemberSortType.StatusDesc;
                                }
                            }
                            else 
                            {
                                loc2 = GuildMemberSortType.TotalContriDesc;
                            }
                        }
                        else 
                        {
                            loc2 = GuildMemberSortType.WeekContriDesc;
                        }
                    }
                    else 
                    {
                        loc2 = GuildMemberSortType.DayContriDesc;
                    }
                }
                else 
                {
                    loc2 = GuildMemberSortType.LevelDesc;
                }
            }
            else 
            {
                loc2 = GuildMemberSortType.PositionDesc;
            }
            Dispatcher.dispatchEvent(new DataEvent(GuildEventName.SortMember, {"sortType": loc2, "isOnlyOnline": this.isOnlyOnline}));
            return;
        }

        public get isOnlyOnline(): Boolean
        {
            return this._isOnlyOnline;
        }

        public set isOnlyOnline(arg1: Boolean)
        {
            this._isOnlyOnline = arg1;
            return;
        }

        public selectMemberByPlayerId(arg1: int): void
        {
            this.tileList.selectedIndex = this.getIndexByPlayerId(arg1);
            return;
        }

        public getIndexByPlayerId(arg1: int): int
        {
            var loc1=0;
            var loc3=null;
            var loc2=this.dataProvider.toArray();
            var loc4=0;
            while (loc4 < loc2.length) 
            {
                loc3 = loc2[loc4];
                if (arg1 == loc3.miniPlayer.entityId.id) 
                {
                    loc1 = loc4;
                    break;
                }
                ++loc4;
            }
            return loc1;
        }

        /* internal */ /* var */_numText: Object /* flash.text.TextField */;

        /* internal */ /* var */_posDescBtn: GButton;

        /* internal */ /* var */_levelDescBtn: GButton;

        /* internal */ /* var */_dayContriDescBtn: GButton;

        /* internal */ /* var */_weekContriDescBtn: GButton;

        /* internal */ /* var */_totalContriDescBtn: GButton;

        /* internal */ /* var */_statusDescBtn: GButton;

        /* internal */ /* var */_isOnlyOnline: Boolean;
    }
